<!DOCTYPE html>
<html>

<head>
    <link rel="stylesheet" href="//at.alicdn.com/t/font_810097_s50gcn082go.css">
    <link rel="stylesheet" href="../../css/common/reset.css">
    <link rel="stylesheet" href="../../layui/css/layui.css">
    <link rel="stylesheet" href="../../css/editreadNum.css">
</head>

<body style="background: #fff;">
    <div class="tzDesBox">
        <h4><i class="iconfont icon-laba"></i>补单量调整规则：</h4>
        <p>1、只可在原单量基础上增加单量。如需减少单量，请在当前单量到期后重新选择。</p>
        <p>2、系统会根据所选单量统计距离到期时间应补交的费用，确认提交则立即扣费。</p>
    </div>
    <form class="layui-form" lay-filter="example">
        <div class="layui-form-item">
            <label class="layui-form-label">店铺名称：</label>
            <div class="layui-input-block">
                <input type="text" class="shopName">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">当前单量：</label>
            <div class="layui-input-block">
                <input type="text" class="billCount">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">到期时间：</label>
            <div class="layui-input-block">
                <input type="text" class="expirationTime">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">调整单量：</label>
            <div class="layui-input-block">
                <input type="radio" name="sex" value="30" title="30单/天" lay-filter="filter" id="thirty-lists">
                <input type="radio" name="sex" value="50" title="50单/天" id="fifty-lists" lay-filter="filter"><span
                    class="redColor" style="line-height: 28px;display: inline-block;vertical-align: bottom;margin-right: 10px;margin-left: -10px;">500元</span>
                <input type="radio" name="sex" value="100" title="100单/天" lay-filter="filter" id="hundred-lists"><span
                    class="redColor" style="line-height: 28px;display: inline-block;vertical-align: bottom;margin-right: 10px;margin-left: -10px;">1000元</span>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit="" lay-filter="changeNumBtn" type="button">立即提交</button>
            </div>
        </div>
    </form>
    <script src="../../js/jquery.min.js"></script>
    <script src="../../js/jquery.cookie.js"></script>
    <script src="../../layui/layui.js"></script>
    <script src="../../js/dataRequest.js"></script>
    <script>
        var mid = $.cookie("id");
        $("form input[type=text]").attr('disabled', true);
        var changeNumInfo = JSON.parse($.cookie('changeNumInfo'));
        var currbill_count = changeNumInfo.billCount;

        $(".shopName").val(changeNumInfo.shopName);
        $(".billCount").val(changeNumInfo.billCount);
        $(".expirationTime").val(changeNumInfo.expirationTime);
        console.log("你是个什么", changeNumInfo);
        //关闭iframe
        $('#closeIframe').click(function () {
            parent.layer.close(index);
        });
        layui.use(['jquery', 'form', 'layer'], function () {
            $ = layui.jquery;
            form = layui.form;
            if (currbill_count == 30) {
                $("#thirty-lists").attr("checked", "checked");
                form.render('radio');
            } else if (currbill_count == 50) {
                $("#fifty-lists").attr("checked", "checked");
                form.render('radio');
            } else {
                $("#hundred-lists").attr("checked", "checked");
                form.render('radio');
            }

            form.on('radio(filter)', function (data) {
                // console.log(data.elem); //得到radio原始DOM对象
                // console.log(data.value); //被点击的radio的value值
                var bill_count = $.cookie("bill_count", data.value);
                console.log("你是我调整的单量", bill_count)
            });
            //监听提交
            form.on('submit(changeNumBtn)', function (data) {
                var shopId = changeNumInfo.id;
                var bill_count = $.cookie("bill_count");
                console.log("店铺Id", shopId);
                var JdateJson = {
                    "id": shopId,
                    "merchantsId": mid,
                    "bill_count": bill_count
                }
                // return;
                $.ajax({
                    url: BASE_URL + MAP_URL + 'order/num',
                    type: 'PUT',
                    dataType: 'json',
                    contentType: "application/json;charset=utf-8",
                    data: JSON.stringify(JdateJson),
                    success: function (data) {
                        console.log("数据是谁", data.data);
                        var _Success = data.code;
                        if (_Success == 200) {
                            layer.msg("修改成功");
                            // return;
                            var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                            setTimeout(function () {
                                parent.layer.close(index);//关闭弹出层
                                parent.location.reload();//更新父级页面（提示：如果需要跳转到其它页面见下文）
                            }, 2000);
                        } else {
                            layer.msg(data.data);
                        }
                    }
                })
                //防止页面跳转
                return false;
            });
        });
    </script>
</body>

</html>